@microsoft/omnichannel-chat-widget 0.1.0-main.9e62ed8 → 0.1.0-main.a27ec4b
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/common/Constants.js +4 -0
- package/lib/cjs/common/storage/default/defaultCacheManager.js +34 -0
- package/lib/cjs/common/storage/default/defaultClientDataStoreProvider.js +114 -0
- package/lib/cjs/common/storage/default/defaultInMemoryDataStore.js +86 -0
- package/lib/cjs/common/telemetry/TelemetryConstants.js +12 -0
- package/lib/cjs/common/utils.js +64 -5
- package/lib/cjs/components/chatbuttonstateful/ChatButtonStateful.js +4 -0
- package/lib/cjs/components/confirmationpanestateful/ConfirmationPaneStateful.js +0 -1
- package/lib/cjs/components/footerstateful/FooterStateful.js +1 -8
- package/lib/cjs/components/headerstateful/HeaderStateful.js +4 -3
- package/lib/cjs/components/livechatwidget/common/ActivityStreamHandler.js +44 -0
- package/lib/cjs/components/livechatwidget/common/ActivitySubscriber/DefaultActivitySubscriber.js +23 -0
- package/lib/cjs/components/livechatwidget/common/ActivitySubscriber/IActivitySubscriber.js +1 -0
- package/lib/cjs/components/livechatwidget/common/ActivitySubscriber/PauseActivitySubscriber.js +39 -0
- package/lib/cjs/components/livechatwidget/common/ChatAdapterShim.js +70 -0
- package/lib/cjs/components/livechatwidget/common/Deferred.js +42 -0
- package/lib/cjs/components/livechatwidget/common/authHelper.js +65 -0
- package/lib/cjs/components/livechatwidget/common/createAdapter.js +13 -1
- package/lib/cjs/components/livechatwidget/common/createFooter.js +7 -16
- package/lib/cjs/components/livechatwidget/common/createInternetConnectionChangeHandler.js +12 -0
- package/lib/cjs/components/livechatwidget/common/createMarkdown.js +31 -30
- package/lib/cjs/components/livechatwidget/common/defaultProps/dummyDefaultProps.js +23 -5
- package/lib/cjs/components/livechatwidget/common/endChat.js +52 -20
- package/lib/cjs/components/livechatwidget/common/initWebChatComposer.js +12 -0
- package/lib/cjs/components/livechatwidget/common/reconnectChatHelper.js +55 -35
- package/lib/cjs/components/livechatwidget/common/setPostChatContextAndLoadSurvey.js +0 -4
- package/lib/cjs/components/livechatwidget/common/shareObservable.js +45 -0
- package/lib/cjs/components/livechatwidget/common/startChat.js +153 -85
- package/lib/cjs/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +188 -116
- package/lib/cjs/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +4 -8
- package/lib/cjs/components/proactivechatpanestateful/ProactiveChatPaneStateful.js +1 -1
- package/lib/cjs/components/webchatcontainerstateful/WebChatContainerStateful.js +16 -2
- package/lib/cjs/components/webchatcontainerstateful/common/defaultProps/defaultWebChatContainerStatefulProps.js +4 -1
- package/lib/cjs/components/webchatcontainerstateful/common/defaultStyles/defaultAdaptiveCardStyles.js +11 -0
- package/lib/cjs/components/webchatcontainerstateful/common/mockchatsdk.js +2 -0
- package/lib/cjs/components/webchatcontainerstateful/interfaces/IAdaptiveCardStyles.js +1 -0
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityStatusMiddleware.js +2 -1
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultReceivedMessageAnchorStyles.js +10 -0
- package/lib/cjs/contexts/common/ConversationState.js +3 -2
- package/lib/cjs/contexts/common/LiveChatWidgetActionType.js +1 -0
- package/lib/cjs/contexts/common/LiveChatWidgetContextInitialState.js +12 -5
- package/lib/cjs/contexts/createReducer.js +8 -0
- package/lib/cjs/controller/componentController.js +2 -2
- package/lib/esm/common/Constants.js +4 -0
- package/lib/esm/common/storage/default/defaultCacheManager.js +19 -0
- package/lib/esm/common/storage/default/defaultClientDataStoreProvider.js +102 -0
- package/lib/esm/common/storage/default/defaultInMemoryDataStore.js +71 -0
- package/lib/esm/common/telemetry/TelemetryConstants.js +12 -0
- package/lib/esm/common/utils.js +48 -3
- package/lib/esm/components/chatbuttonstateful/ChatButtonStateful.js +4 -0
- package/lib/esm/components/confirmationpanestateful/ConfirmationPaneStateful.js +0 -1
- package/lib/esm/components/footerstateful/FooterStateful.js +1 -8
- package/lib/esm/components/headerstateful/HeaderStateful.js +4 -3
- package/lib/esm/components/livechatwidget/common/ActivityStreamHandler.js +34 -0
- package/lib/esm/components/livechatwidget/common/ActivitySubscriber/DefaultActivitySubscriber.js +14 -0
- package/lib/esm/components/livechatwidget/common/ActivitySubscriber/IActivitySubscriber.js +1 -0
- package/lib/esm/components/livechatwidget/common/ActivitySubscriber/PauseActivitySubscriber.js +29 -0
- package/lib/esm/components/livechatwidget/common/ChatAdapterShim.js +59 -0
- package/lib/esm/components/livechatwidget/common/Deferred.js +33 -0
- package/lib/esm/components/livechatwidget/common/authHelper.js +50 -0
- package/lib/esm/components/livechatwidget/common/createAdapter.js +12 -2
- package/lib/esm/components/livechatwidget/common/createFooter.js +4 -15
- package/lib/esm/components/livechatwidget/common/createInternetConnectionChangeHandler.js +8 -0
- package/lib/esm/components/livechatwidget/common/createMarkdown.js +31 -30
- package/lib/esm/components/livechatwidget/common/defaultProps/dummyDefaultProps.js +23 -5
- package/lib/esm/components/livechatwidget/common/endChat.js +53 -21
- package/lib/esm/components/livechatwidget/common/initWebChatComposer.js +13 -2
- package/lib/esm/components/livechatwidget/common/reconnectChatHelper.js +56 -37
- package/lib/esm/components/livechatwidget/common/setPostChatContextAndLoadSurvey.js +0 -4
- package/lib/esm/components/livechatwidget/common/shareObservable.js +38 -0
- package/lib/esm/components/livechatwidget/common/startChat.js +148 -86
- package/lib/esm/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +188 -117
- package/lib/esm/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +5 -8
- package/lib/esm/components/proactivechatpanestateful/ProactiveChatPaneStateful.js +1 -1
- package/lib/esm/components/webchatcontainerstateful/WebChatContainerStateful.js +14 -2
- package/lib/esm/components/webchatcontainerstateful/common/defaultProps/defaultWebChatContainerStatefulProps.js +3 -1
- package/lib/esm/components/webchatcontainerstateful/common/defaultStyles/defaultAdaptiveCardStyles.js +4 -0
- package/lib/esm/components/webchatcontainerstateful/common/mockchatsdk.js +2 -0
- package/lib/esm/components/webchatcontainerstateful/interfaces/IAdaptiveCardStyles.js +1 -0
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityStatusMiddleware.js +2 -1
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultReceivedMessageAnchorStyles.js +3 -0
- package/lib/esm/contexts/common/ConversationState.js +3 -2
- package/lib/esm/contexts/common/LiveChatWidgetActionType.js +1 -0
- package/lib/esm/contexts/common/LiveChatWidgetContextInitialState.js +10 -5
- package/lib/esm/contexts/createReducer.js +8 -0
- package/lib/esm/controller/componentController.js +2 -2
- package/lib/types/common/Constants.d.ts +2 -0
- package/lib/types/common/storage/default/defaultCacheManager.d.ts +4 -0
- package/lib/types/common/storage/default/defaultClientDataStoreProvider.d.ts +2 -0
- package/lib/types/common/storage/default/defaultInMemoryDataStore.d.ts +6 -0
- package/lib/types/common/telemetry/TelemetryConstants.d.ts +11 -2
- package/lib/types/common/utils.d.ts +7 -3
- package/lib/types/components/headerstateful/interfaces/IHeaderStatefulParams.d.ts +2 -1
- package/lib/types/components/livechatwidget/common/ActivityStreamHandler.d.ts +14 -0
- package/lib/types/components/livechatwidget/common/ActivitySubscriber/DefaultActivitySubscriber.d.ts +5 -0
- package/lib/types/components/livechatwidget/common/ActivitySubscriber/IActivitySubscriber.d.ts +6 -0
- package/lib/types/components/livechatwidget/common/ActivitySubscriber/PauseActivitySubscriber.d.ts +7 -0
- package/lib/types/components/livechatwidget/common/ChatAdapterShim.d.ts +7 -0
- package/lib/types/components/livechatwidget/common/Deferred.d.ts +9 -0
- package/lib/types/components/livechatwidget/common/authHelper.d.ts +5 -0
- package/lib/types/components/livechatwidget/common/reconnectChatHelper.d.ts +5 -4
- package/lib/types/components/livechatwidget/common/shareObservable.d.ts +1 -0
- package/lib/types/components/livechatwidget/common/startChat.d.ts +4 -2
- package/lib/types/components/livechatwidget/interfaces/ILiveChatWidgetControlProps.d.ts +1 -0
- package/lib/types/components/livechatwidget/interfaces/ILiveChatWidgetProps.d.ts +1 -0
- package/lib/types/components/reconnectchatpanestateful/interfaces/IReconnectChatPaneStatefulProps.d.ts +0 -1
- package/lib/types/components/webchatcontainerstateful/common/defaultStyles/defaultAdaptiveCardStyles.d.ts +2 -0
- package/lib/types/components/webchatcontainerstateful/common/mockchatsdk.d.ts +1 -0
- package/lib/types/components/webchatcontainerstateful/interfaces/IAdaptiveCardStyles.d.ts +4 -0
- package/lib/types/components/webchatcontainerstateful/interfaces/IRenderingMiddlewareProps.d.ts +2 -1
- package/lib/types/components/webchatcontainerstateful/interfaces/IWebChatContainerStatefulProps.d.ts +2 -0
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityStatusMiddleware.d.ts +1 -1
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultReceivedMessageAnchorStyles.d.ts +2 -0
- package/lib/types/contexts/common/ConversationState.d.ts +3 -2
- package/lib/types/contexts/common/ILiveChatWidgetContext.d.ts +1 -1
- package/lib/types/contexts/common/LiveChatWidgetActionType.d.ts +2 -1
- package/lib/types/contexts/common/LiveChatWidgetContextInitialState.d.ts +1 -2
- package/package.json +4 -3
|
@@ -167,6 +167,10 @@ _defineProperty(Constants, "internetConnectionTestUrlText", "Omnichannel Connect
|
|
|
167
167
|
|
|
168
168
|
_defineProperty(Constants, "ChatWidgetStateChangedPrefix", "ChatWidgetStateChanged");
|
|
169
169
|
|
|
170
|
+
_defineProperty(Constants, "PostChatLoadingDurationInMs", 2000);
|
|
171
|
+
|
|
172
|
+
_defineProperty(Constants, "BrowserUnloadConfirmationMessage", "Do you want to leave chat?");
|
|
173
|
+
|
|
170
174
|
const Regex = (_class = class Regex {}, _defineProperty(_class, "EmailRegex", "(?:[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+)*|\"(?:[\\x01-\\x08\\x0b\\x0c\\x0e-\\x1f\\x21\\x23-\\x5b\\x5d-\\x7f]|\\\\[\\x01-\\x09\\x0b\\x0c\\x0e-\\x7f])*\")@(?:(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?\\.)+[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?|\\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-zA-Z0-9-]*[a-zA-Z0-9]:(?:[\\x01-\\x08\\x0b\\x0c\\x0e-\\x1f\\x21-\\x5a\\x53-\\x7f]|\\\\[\\x01-\\x09\\x0b\\x0c\\x0e-\\x7f])+)\\])"), _class);
|
|
171
175
|
exports.Regex = Regex;
|
|
172
176
|
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.registerBroadcastServiceForLocalStorage = exports.defaultCacheManager = void 0;
|
|
7
|
+
|
|
8
|
+
var _omnichannelChatComponents = require("@microsoft/omnichannel-chat-components");
|
|
9
|
+
|
|
10
|
+
var _utils = require("../../utils");
|
|
11
|
+
|
|
12
|
+
var _defaultClientDataStoreProvider = require("./defaultClientDataStoreProvider");
|
|
13
|
+
|
|
14
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
15
|
+
|
|
16
|
+
class defaultCacheManager {}
|
|
17
|
+
|
|
18
|
+
exports.defaultCacheManager = defaultCacheManager;
|
|
19
|
+
|
|
20
|
+
_defineProperty(defaultCacheManager, "InternalCache", {});
|
|
21
|
+
|
|
22
|
+
const registerBroadcastServiceForLocalStorage = (orgid, widgetId, widgetInstanceId) => {
|
|
23
|
+
const widgetCacheId = (0, _utils.getWidgetCacheId)(orgid, widgetId, widgetInstanceId);
|
|
24
|
+
|
|
25
|
+
_omnichannelChatComponents.BroadcastService.getMessageByEventName(widgetCacheId).subscribe(msg => {
|
|
26
|
+
try {
|
|
27
|
+
(0, _defaultClientDataStoreProvider.defaultClientDataStoreProvider)().setData(widgetCacheId, JSON.stringify(msg.payload), "localStorage");
|
|
28
|
+
} catch (error) {
|
|
29
|
+
console.error("Error in setting data to localstorage", error);
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
exports.registerBroadcastServiceForLocalStorage = registerBroadcastServiceForLocalStorage;
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.defaultClientDataStoreProvider = void 0;
|
|
7
|
+
|
|
8
|
+
var _defaultInMemoryDataStore = require("./defaultInMemoryDataStore");
|
|
9
|
+
|
|
10
|
+
var _TelemetryHelper = require("../../telemetry/TelemetryHelper");
|
|
11
|
+
|
|
12
|
+
var _TelemetryConstants = require("../../telemetry/TelemetryConstants");
|
|
13
|
+
|
|
14
|
+
const defaultClientDataStoreProvider = () => {
|
|
15
|
+
const isCookieAllowed = () => {
|
|
16
|
+
try {
|
|
17
|
+
localStorage;
|
|
18
|
+
sessionStorage;
|
|
19
|
+
return true;
|
|
20
|
+
} catch (error) {
|
|
21
|
+
console.error("Third party cookie blocked");
|
|
22
|
+
return false;
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
const TtlInMs = 15 * 60 * 1000; // 15 mins
|
|
27
|
+
|
|
28
|
+
const dataStoreProvider = {
|
|
29
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
30
|
+
setData: (key, data, type) => {
|
|
31
|
+
if (isCookieAllowed()) {
|
|
32
|
+
try {
|
|
33
|
+
if (key) {
|
|
34
|
+
const now = new Date();
|
|
35
|
+
const item = {
|
|
36
|
+
data: data,
|
|
37
|
+
expiry: now.getTime() + TtlInMs
|
|
38
|
+
};
|
|
39
|
+
const strItem = JSON.stringify(item);
|
|
40
|
+
|
|
41
|
+
if (type === "localStorage") {
|
|
42
|
+
localStorage.setItem(key, strItem);
|
|
43
|
+
} else {
|
|
44
|
+
sessionStorage.setItem(key, strItem);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
} catch (error) {
|
|
48
|
+
_TelemetryHelper.TelemetryHelper.logConfigDataEvent(_TelemetryConstants.LogLevel.ERROR, {
|
|
49
|
+
Event: _TelemetryConstants.TelemetryEvent.ClientDataStoreProviderFailed,
|
|
50
|
+
ExceptionDetails: error,
|
|
51
|
+
Description: "Unable to store data in localStorage."
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
} else {
|
|
55
|
+
const dataToCache = {
|
|
56
|
+
key: key,
|
|
57
|
+
data: data,
|
|
58
|
+
type: type
|
|
59
|
+
};
|
|
60
|
+
parent.postMessage(dataToCache, "*");
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
64
|
+
getData: (key, type) => {
|
|
65
|
+
if (isCookieAllowed()) {
|
|
66
|
+
let item;
|
|
67
|
+
|
|
68
|
+
if (type === "localStorage") {
|
|
69
|
+
item = localStorage.getItem(key);
|
|
70
|
+
} else {
|
|
71
|
+
item = sessionStorage.getItem(key);
|
|
72
|
+
} //Return item if not expired
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
let itemInJson = undefined;
|
|
76
|
+
|
|
77
|
+
if (item !== null) {
|
|
78
|
+
itemInJson = JSON.parse(item);
|
|
79
|
+
const now = new Date(); // compare the expiry time of the item with the current time
|
|
80
|
+
|
|
81
|
+
if (now.getTime() > itemInJson.expiry) {
|
|
82
|
+
// If the item is expired, delete the item from storage
|
|
83
|
+
// and return null
|
|
84
|
+
localStorage.removeItem(key);
|
|
85
|
+
return null;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
return itemInJson.data;
|
|
89
|
+
}
|
|
90
|
+
} else {
|
|
91
|
+
// get data from in memory db when cookie is disabled
|
|
92
|
+
return (0, _defaultInMemoryDataStore.inMemoryDataStore)().getData(key);
|
|
93
|
+
}
|
|
94
|
+
},
|
|
95
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
96
|
+
removeData: (key, type) => {
|
|
97
|
+
if (isCookieAllowed()) {
|
|
98
|
+
if (key) {
|
|
99
|
+
if (type === "localStorage") {
|
|
100
|
+
return localStorage.removeItem(key);
|
|
101
|
+
} else {
|
|
102
|
+
return sessionStorage.removeItem(key);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
} else {
|
|
106
|
+
// get data from in memory db when cookie is disabled
|
|
107
|
+
return (0, _defaultInMemoryDataStore.inMemoryDataStore)().removeData(key);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
return dataStoreProvider;
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
exports.defaultClientDataStoreProvider = defaultClientDataStoreProvider;
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.inMemoryDataStore = exports.defaultInitializeInMemoryDataStore = void 0;
|
|
7
|
+
|
|
8
|
+
var _TelemetryConstants = require("../../telemetry/TelemetryConstants");
|
|
9
|
+
|
|
10
|
+
var _TelemetryHelper = require("../../telemetry/TelemetryHelper");
|
|
11
|
+
|
|
12
|
+
var _defaultCacheManager = require("./defaultCacheManager");
|
|
13
|
+
|
|
14
|
+
const defaultInitializeInMemoryDataStore = widgetId => {
|
|
15
|
+
try {
|
|
16
|
+
localStorage;
|
|
17
|
+
} catch (error) {
|
|
18
|
+
// Register below events when localStorage is not accessible
|
|
19
|
+
// Listening to event raised from client browser
|
|
20
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
21
|
+
window.addEventListener("message", function (e) {
|
|
22
|
+
try {
|
|
23
|
+
if (e.data.key) {
|
|
24
|
+
const browserData = e.data;
|
|
25
|
+
|
|
26
|
+
if (_defaultCacheManager.defaultCacheManager.InternalCache[browserData.key]) {
|
|
27
|
+
delete _defaultCacheManager.defaultCacheManager.InternalCache[browserData.key];
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
_defaultCacheManager.defaultCacheManager.InternalCache[browserData.key] = browserData.data;
|
|
31
|
+
}
|
|
32
|
+
} catch (error) {
|
|
33
|
+
_TelemetryHelper.TelemetryHelper.logConfigDataEvent(_TelemetryConstants.LogLevel.ERROR, {
|
|
34
|
+
Event: _TelemetryConstants.TelemetryEvent.InMemoryDataStoreFailed,
|
|
35
|
+
ExceptionDetails: error,
|
|
36
|
+
Description: "Unable to register default in-memory cache."
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
}); // send cache initialize message to client
|
|
40
|
+
|
|
41
|
+
if (_defaultCacheManager.defaultCacheManager.InternalCache === undefined || {}) {
|
|
42
|
+
parent.postMessage({
|
|
43
|
+
data: "cacheinitialize",
|
|
44
|
+
widgetId: widgetId
|
|
45
|
+
}, "*");
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
exports.defaultInitializeInMemoryDataStore = defaultInitializeInMemoryDataStore;
|
|
51
|
+
|
|
52
|
+
const inMemoryDataStore = () => {
|
|
53
|
+
const dataStoreProvider = {
|
|
54
|
+
getData: key => {
|
|
55
|
+
if (_defaultCacheManager.defaultCacheManager.InternalCache && _defaultCacheManager.defaultCacheManager.InternalCache[key]) {
|
|
56
|
+
return _defaultCacheManager.defaultCacheManager.InternalCache[key];
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
60
|
+
setData: (key, data) => {
|
|
61
|
+
try {
|
|
62
|
+
_defaultCacheManager.defaultCacheManager.InternalCache[key] = data;
|
|
63
|
+
} catch (error) {
|
|
64
|
+
_TelemetryHelper.TelemetryHelper.logConfigDataEvent(_TelemetryConstants.LogLevel.ERROR, {
|
|
65
|
+
Event: _TelemetryConstants.TelemetryEvent.InMemoryDataStoreFailed,
|
|
66
|
+
ExceptionDetails: error,
|
|
67
|
+
Description: "Unable to set data in default in-memory cache."
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
removeData: key => {
|
|
72
|
+
try {
|
|
73
|
+
_defaultCacheManager.defaultCacheManager.InternalCache[key] = {};
|
|
74
|
+
} catch (error) {
|
|
75
|
+
_TelemetryHelper.TelemetryHelper.logConfigDataEvent(_TelemetryConstants.LogLevel.ERROR, {
|
|
76
|
+
Event: _TelemetryConstants.TelemetryEvent.InMemoryDataStoreFailed,
|
|
77
|
+
ExceptionDetails: error,
|
|
78
|
+
Description: "Unable to remove data from default in-memory cache."
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
return dataStoreProvider;
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
exports.inMemoryDataStore = inMemoryDataStore;
|
|
@@ -59,6 +59,7 @@ exports.BroadcastEvent = BroadcastEvent;
|
|
|
59
59
|
BroadcastEvent["ChatInitiated"] = "ChatInitiated";
|
|
60
60
|
BroadcastEvent["CloseChat"] = "CloseChat";
|
|
61
61
|
BroadcastEvent["InitiateEndChatOnBrowserUnload"] = "InitiateEndChatOnBrowserUnload";
|
|
62
|
+
BroadcastEvent["ClosePopoutWindow"] = "ClosePopoutWindow";
|
|
62
63
|
})(BroadcastEvent || (exports.BroadcastEvent = BroadcastEvent = {}));
|
|
63
64
|
|
|
64
65
|
let TelemetryEvent;
|
|
@@ -100,6 +101,8 @@ exports.TelemetryEvent = TelemetryEvent;
|
|
|
100
101
|
TelemetryEvent["PostChatContextCallSucceed"] = "PostChatContextCallSucceed";
|
|
101
102
|
TelemetryEvent["PostChatContextCallFailed"] = "PostChatContextCallFailed";
|
|
102
103
|
TelemetryEvent["ParseAdaptiveCardFailed"] = "ParseAdaptiveCardFailed";
|
|
104
|
+
TelemetryEvent["ClientDataStoreProviderFailed"] = "ClientDataStoreProviderFailed";
|
|
105
|
+
TelemetryEvent["InMemoryDataStoreFailed"] = "InMemoryDataStoreFailed";
|
|
103
106
|
TelemetryEvent["WebChatLoaded"] = "WebChatLoaded";
|
|
104
107
|
TelemetryEvent["LCWChatButtonClicked"] = "LCWChatButtonClicked";
|
|
105
108
|
TelemetryEvent["LCWChatButtonShow"] = "LCWChatButtonShow";
|
|
@@ -140,6 +143,10 @@ exports.TelemetryEvent = TelemetryEvent;
|
|
|
140
143
|
TelemetryEvent["AudioToggleButtonClicked"] = "AudioToggleButtonClicked";
|
|
141
144
|
TelemetryEvent["SuppressBotMagicCodeSucceeded"] = "SuppressBotMagicCodeSucceeded";
|
|
142
145
|
TelemetryEvent["SuppressBotMagicCodeFailed"] = "SuppressBotMagicCodeFailed";
|
|
146
|
+
TelemetryEvent["GetConversationDetailsException"] = "GetConversationDetailsException";
|
|
147
|
+
TelemetryEvent["BrowserUnloadEventStarted"] = "BrowserUnloadEventStarted";
|
|
148
|
+
TelemetryEvent["GetAuthTokenCalled"] = "GetAuthTokenCalled";
|
|
149
|
+
TelemetryEvent["ReceivedNullOrEmptyToken"] = "ReceivedNullOrEmptyToken";
|
|
143
150
|
TelemetryEvent["ProcessingHTMLTextMiddlewareFailed"] = "ProcessingHTMLTextMiddlewareFailed";
|
|
144
151
|
TelemetryEvent["ProcessingSanitizationMiddlewareFailed"] = "ProcessingSanitizationMiddlewareFailed";
|
|
145
152
|
TelemetryEvent["FormatTagsMiddlewareJSONStringifyFailed"] = "FormatTagsMiddlewareJSONStringifyFailed";
|
|
@@ -166,6 +173,8 @@ exports.TelemetryEvent = TelemetryEvent;
|
|
|
166
173
|
TelemetryEvent["MessageSent"] = "MessageSent";
|
|
167
174
|
TelemetryEvent["MessageReceived"] = "MessageReceived";
|
|
168
175
|
TelemetryEvent["CustomContextReceived"] = "CustomContextReceived";
|
|
176
|
+
TelemetryEvent["NetworkDisconnected"] = "NetworkDisconnected";
|
|
177
|
+
TelemetryEvent["NetworkReconnected"] = "NetworkReconnected";
|
|
169
178
|
})(TelemetryEvent || (exports.TelemetryEvent = TelemetryEvent = {}));
|
|
170
179
|
|
|
171
180
|
class TelemetryConstants {
|
|
@@ -211,6 +220,9 @@ class TelemetryConstants {
|
|
|
211
220
|
case TelemetryEvent.MessageSent:
|
|
212
221
|
case TelemetryEvent.MessageReceived:
|
|
213
222
|
case TelemetryEvent.CustomContextReceived:
|
|
223
|
+
case TelemetryEvent.BrowserUnloadEventStarted:
|
|
224
|
+
case TelemetryEvent.NetworkDisconnected:
|
|
225
|
+
case TelemetryEvent.NetworkReconnected:
|
|
214
226
|
return ScenarioType.ACTIONS;
|
|
215
227
|
|
|
216
228
|
case TelemetryEvent.StartChatSDKCall:
|
package/lib/cjs/common/utils.js
CHANGED
|
@@ -3,14 +3,18 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.setTabIndices = exports.setFocusOnSendBox = exports.setFocusOnElement = exports.preventFocusToMoveOutOfElement = exports.parseAdaptiveCardPayload = exports.newGuid = exports.isNullOrUndefined = exports.isNullOrEmptyString = exports.getWidgetEndChatEventName = exports.getWidgetCacheId = exports.getTimestampHourMinute = exports.getLocaleDirection = exports.getIconText = exports.getDomain = exports.findParentFocusableElementsWithoutChildContainer = exports.findAllFocusableElement = exports.extractPreChatSurveyResponseValues = exports.escapeHtml = exports.createTimer = exports.changeLanguageCodeFormatForWebChat = void 0;
|
|
6
|
+
exports.setTabIndices = exports.setFocusOnSendBox = exports.setFocusOnElement = exports.preventFocusToMoveOutOfElement = exports.parseAdaptiveCardPayload = exports.newGuid = exports.isUndefinedOrEmpty = exports.isNullOrUndefined = exports.isNullOrEmptyString = exports.getWidgetEndChatEventName = exports.getWidgetCacheId = exports.getTimestampHourMinute = exports.getStateFromCache = exports.getLocaleDirection = exports.getIconText = exports.getDomain = exports.getBroadcastChannelName = exports.findParentFocusableElementsWithoutChildContainer = exports.findAllFocusableElement = exports.extractPreChatSurveyResponseValues = exports.escapeHtml = exports.createTimer = exports.changeLanguageCodeFormatForWebChat = exports.addDelayInMs = void 0;
|
|
7
7
|
|
|
8
8
|
var _Constants = require("./Constants");
|
|
9
9
|
|
|
10
|
+
var _DataStoreManager = require("./contextDataStore/DataStoreManager");
|
|
11
|
+
|
|
10
12
|
var _KeyCodes = require("./KeyCodes");
|
|
11
13
|
|
|
12
14
|
var _TelemetryConstants = require("./telemetry/TelemetryConstants");
|
|
13
15
|
|
|
16
|
+
var _md5Typescript = require("md5-typescript");
|
|
17
|
+
|
|
14
18
|
const getElementBySelector = selector => {
|
|
15
19
|
let element;
|
|
16
20
|
|
|
@@ -352,14 +356,69 @@ const getDomain = hostValue => {
|
|
|
352
356
|
|
|
353
357
|
exports.getDomain = getDomain;
|
|
354
358
|
|
|
355
|
-
const getWidgetCacheId = (orgId, widgetId) => {
|
|
356
|
-
|
|
359
|
+
const getWidgetCacheId = (orgId, widgetId, widgetInstanceId) => {
|
|
360
|
+
const widgetCacheId = `${widgetInstanceId}_${orgId}_${widgetId}`;
|
|
361
|
+
return _md5Typescript.Md5.init(widgetCacheId);
|
|
357
362
|
};
|
|
358
363
|
|
|
359
364
|
exports.getWidgetCacheId = getWidgetCacheId;
|
|
360
365
|
|
|
361
|
-
const getWidgetEndChatEventName = (orgId, widgetId) => {
|
|
366
|
+
const getWidgetEndChatEventName = (orgId, widgetId, widgetInstanceId) => {
|
|
367
|
+
if (!isNullOrEmptyString(widgetInstanceId)) {
|
|
368
|
+
return `${_TelemetryConstants.BroadcastEvent.ChatEnded}_${widgetInstanceId}_${orgId}_${widgetId}`;
|
|
369
|
+
}
|
|
370
|
+
|
|
362
371
|
return `${_TelemetryConstants.BroadcastEvent.ChatEnded}_${orgId}_${widgetId}`;
|
|
372
|
+
}; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
373
|
+
|
|
374
|
+
|
|
375
|
+
exports.getWidgetEndChatEventName = getWidgetEndChatEventName;
|
|
376
|
+
|
|
377
|
+
const getStateFromCache = (orgId, widgetId, widgetInstanceId) => {
|
|
378
|
+
// Getting updated state from cache
|
|
379
|
+
try {
|
|
380
|
+
if (_DataStoreManager.DataStoreManager.clientDataStore) {
|
|
381
|
+
var _DataStoreManager$cli;
|
|
382
|
+
|
|
383
|
+
const widgetStateEventName = getWidgetCacheId(orgId, widgetId, widgetInstanceId);
|
|
384
|
+
const widgetStateFromCache = (_DataStoreManager$cli = _DataStoreManager.DataStoreManager.clientDataStore) === null || _DataStoreManager$cli === void 0 ? void 0 : _DataStoreManager$cli.getData(widgetStateEventName, "localStorage");
|
|
385
|
+
const persistedState = widgetStateFromCache ? JSON.parse(widgetStateFromCache) : undefined;
|
|
386
|
+
return persistedState;
|
|
387
|
+
} else {
|
|
388
|
+
return null;
|
|
389
|
+
}
|
|
390
|
+
} catch (error) {
|
|
391
|
+
console.log(error);
|
|
392
|
+
return null;
|
|
393
|
+
}
|
|
394
|
+
}; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
395
|
+
|
|
396
|
+
|
|
397
|
+
exports.getStateFromCache = getStateFromCache;
|
|
398
|
+
|
|
399
|
+
const isUndefinedOrEmpty = object => {
|
|
400
|
+
if (object) {
|
|
401
|
+
if (Object.keys(object).length === 0) {
|
|
402
|
+
return true;
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
return false;
|
|
406
|
+
} else {
|
|
407
|
+
return true;
|
|
408
|
+
}
|
|
409
|
+
}; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
410
|
+
|
|
411
|
+
|
|
412
|
+
exports.isUndefinedOrEmpty = isUndefinedOrEmpty;
|
|
413
|
+
|
|
414
|
+
const addDelayInMs = ms => {
|
|
415
|
+
return new Promise(resolve => setTimeout(resolve, ms));
|
|
416
|
+
};
|
|
417
|
+
|
|
418
|
+
exports.addDelayInMs = addDelayInMs;
|
|
419
|
+
|
|
420
|
+
const getBroadcastChannelName = (widgetId, widgetInstanceId) => {
|
|
421
|
+
return widgetInstanceId && !isNullOrEmptyString(widgetInstanceId) ? `${widgetInstanceId}_${widgetId}` : widgetId;
|
|
363
422
|
};
|
|
364
423
|
|
|
365
|
-
exports.
|
|
424
|
+
exports.getBroadcastChannelName = getBroadcastChannelName;
|
|
@@ -82,6 +82,10 @@ const ChatButtonStateful = props => {
|
|
|
82
82
|
titleText: "We're Offline",
|
|
83
83
|
subtitleText: "No agents available",
|
|
84
84
|
onClick: async () => {
|
|
85
|
+
_TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.INFO, {
|
|
86
|
+
Event: _TelemetryConstants.TelemetryEvent.LCWChatButtonClicked
|
|
87
|
+
});
|
|
88
|
+
|
|
85
89
|
if (state.appStates.isMinimized) {
|
|
86
90
|
dispatch({
|
|
87
91
|
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_MINIMIZED,
|
|
@@ -41,7 +41,6 @@ const ConfirmationPaneStateful = props => {
|
|
|
41
41
|
const {
|
|
42
42
|
prepareEndChat
|
|
43
43
|
} = props; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
44
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
45
44
|
|
|
46
45
|
const [adapter] = (0, _useChatAdapterStore.default)();
|
|
47
46
|
const controlProps = {
|
|
@@ -110,14 +110,7 @@ const FooterStateful = props => {
|
|
|
110
110
|
isAudioMuted: state.appStates.isAudioMuted
|
|
111
111
|
}
|
|
112
112
|
};
|
|
113
|
-
|
|
114
|
-
const footer = document.getElementById(footerId);
|
|
115
|
-
|
|
116
|
-
if (footer) {
|
|
117
|
-
footer.style.display = hideFooterDisplay ? "none" : "";
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_omnichannelChatComponents.Footer, {
|
|
113
|
+
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, !hideFooterDisplay && /*#__PURE__*/_react.default.createElement(_omnichannelChatComponents.Footer, {
|
|
121
114
|
componentOverrides: footerProps === null || footerProps === void 0 ? void 0 : footerProps.componentOverrides,
|
|
122
115
|
controlProps: controlProps,
|
|
123
116
|
styleProps: footerProps === null || footerProps === void 0 ? void 0 : footerProps.styleProps
|
|
@@ -72,7 +72,8 @@ const HeaderStateful = props => {
|
|
|
72
72
|
} else {
|
|
73
73
|
const skipEndChatSDK = true;
|
|
74
74
|
const skipCloseChat = false;
|
|
75
|
-
|
|
75
|
+
const postMessageToOtherTabs = true;
|
|
76
|
+
await endChat(adapter, skipEndChatSDK, skipCloseChat, postMessageToOtherTabs);
|
|
76
77
|
}
|
|
77
78
|
|
|
78
79
|
dispatch({
|
|
@@ -81,8 +82,8 @@ const HeaderStateful = props => {
|
|
|
81
82
|
});
|
|
82
83
|
},
|
|
83
84
|
...(headerProps === null || headerProps === void 0 ? void 0 : headerProps.controlProps),
|
|
84
|
-
hideTitle: state.appStates.conversationState === _ConversationState.ConversationState.Loading || (headerProps === null || headerProps === void 0 ? void 0 : (_headerProps$controlP = headerProps.controlProps) === null || _headerProps$controlP === void 0 ? void 0 : _headerProps$controlP.hideTitle),
|
|
85
|
-
hideIcon: state.appStates.conversationState === _ConversationState.ConversationState.Loading || (headerProps === null || headerProps === void 0 ? void 0 : (_headerProps$controlP2 = headerProps.controlProps) === null || _headerProps$controlP2 === void 0 ? void 0 : _headerProps$controlP2.hideIcon),
|
|
85
|
+
hideTitle: state.appStates.conversationState === _ConversationState.ConversationState.Loading || state.appStates.conversationState === _ConversationState.ConversationState.PostchatLoading || (headerProps === null || headerProps === void 0 ? void 0 : (_headerProps$controlP = headerProps.controlProps) === null || _headerProps$controlP === void 0 ? void 0 : _headerProps$controlP.hideTitle),
|
|
86
|
+
hideIcon: state.appStates.conversationState === _ConversationState.ConversationState.Loading || state.appStates.conversationState === _ConversationState.ConversationState.PostchatLoading || (headerProps === null || headerProps === void 0 ? void 0 : (_headerProps$controlP2 = headerProps.controlProps) === null || _headerProps$controlP2 === void 0 ? void 0 : _headerProps$controlP2.hideIcon),
|
|
86
87
|
hideCloseButton: state.appStates.conversationState === _ConversationState.ConversationState.Loading || state.appStates.conversationState === _ConversationState.ConversationState.Prechat || state.appStates.conversationState === _ConversationState.ConversationState.ReconnectChat || (headerProps === null || headerProps === void 0 ? void 0 : (_headerProps$controlP3 = headerProps.controlProps) === null || _headerProps$controlP3 === void 0 ? void 0 : _headerProps$controlP3.hideCloseButton)
|
|
87
88
|
};
|
|
88
89
|
const outOfOfficeControlProps = {
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.ActivityStreamHandler = void 0;
|
|
7
|
+
|
|
8
|
+
var _Deferred = require("./Deferred");
|
|
9
|
+
|
|
10
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
11
|
+
|
|
12
|
+
class ActivityStreamHandler {
|
|
13
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
14
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Use of a deferred pattern, to hold the execution of the activity.
|
|
18
|
+
*
|
|
19
|
+
* */
|
|
20
|
+
static cork() {
|
|
21
|
+
ActivityStreamHandler.restoreDeferred = new _Deferred.Deferred();
|
|
22
|
+
ActivityStreamHandler.restorePromise = ActivityStreamHandler.restoreDeferred.promise;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Resolve the promise, releasing it to continue with the execution of the activity.
|
|
26
|
+
*
|
|
27
|
+
* */
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
static uncork() {
|
|
31
|
+
ActivityStreamHandler.restoreDeferred.resolve();
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
exports.ActivityStreamHandler = ActivityStreamHandler;
|
|
37
|
+
|
|
38
|
+
_defineProperty(ActivityStreamHandler, "restoreDeferred", {
|
|
39
|
+
resolve: () => {
|
|
40
|
+
return "initialState";
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
_defineProperty(ActivityStreamHandler, "restorePromise", void 0);
|
package/lib/cjs/components/livechatwidget/common/ActivitySubscriber/DefaultActivitySubscriber.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.DefaultActivitySubscriber = void 0;
|
|
7
|
+
|
|
8
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
9
|
+
|
|
10
|
+
class DefaultActivitySubscriber {
|
|
11
|
+
constructor() {
|
|
12
|
+
_defineProperty(this, "observer", void 0);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
16
|
+
async next(activity) {
|
|
17
|
+
this.observer.next(activity);
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
exports.DefaultActivitySubscriber = DefaultActivitySubscriber;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|
package/lib/cjs/components/livechatwidget/common/ActivitySubscriber/PauseActivitySubscriber.js
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.PauseActivitySubscriber = void 0;
|
|
7
|
+
|
|
8
|
+
var _ActivityStreamHandler = require("../ActivityStreamHandler");
|
|
9
|
+
|
|
10
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
11
|
+
|
|
12
|
+
class PauseActivitySubscriber {
|
|
13
|
+
constructor() {
|
|
14
|
+
_defineProperty(this, "observer", void 0);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
18
|
+
async apply(activity) {
|
|
19
|
+
await _ActivityStreamHandler.ActivityStreamHandler.restorePromise;
|
|
20
|
+
return activity;
|
|
21
|
+
} // eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
applicable(activity) {
|
|
25
|
+
return true;
|
|
26
|
+
} // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
async next(activity) {
|
|
30
|
+
if (this.applicable(activity)) {
|
|
31
|
+
return await this.apply(activity);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return activity;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
exports.PauseActivitySubscriber = PauseActivitySubscriber;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.ChatAdapterShim = void 0;
|
|
7
|
+
|
|
8
|
+
var _DefaultActivitySubscriber = require("./ActivitySubscriber/DefaultActivitySubscriber");
|
|
9
|
+
|
|
10
|
+
var _shareObservable = require("./shareObservable");
|
|
11
|
+
|
|
12
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
13
|
+
|
|
14
|
+
class ChatAdapterShim {
|
|
15
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
16
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
17
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
18
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
19
|
+
constructor(chatAdapter) {
|
|
20
|
+
_defineProperty(this, "chatAdapter", void 0);
|
|
21
|
+
|
|
22
|
+
_defineProperty(this, "activityObserver", void 0);
|
|
23
|
+
|
|
24
|
+
_defineProperty(this, "subscribers", void 0);
|
|
25
|
+
|
|
26
|
+
this.subscribers = [];
|
|
27
|
+
this.chatAdapter = { ...chatAdapter,
|
|
28
|
+
activity$: (0, _shareObservable.shareObservable)( // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
29
|
+
new window.Observable(observer => {
|
|
30
|
+
this.activityObserver = observer; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
31
|
+
|
|
32
|
+
const abortController = new window.AbortController();
|
|
33
|
+
|
|
34
|
+
(async () => {
|
|
35
|
+
try {
|
|
36
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
37
|
+
for await (let activity of chatAdapter.activities({
|
|
38
|
+
signal: abortController.signal
|
|
39
|
+
})) {
|
|
40
|
+
for (const subscriber of [...this.subscribers, new _DefaultActivitySubscriber.DefaultActivitySubscriber()]) {
|
|
41
|
+
subscriber.observer = this.activityObserver;
|
|
42
|
+
activity = await subscriber.next(activity);
|
|
43
|
+
|
|
44
|
+
if (!activity) {
|
|
45
|
+
break;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
observer.complete();
|
|
51
|
+
} catch (error) {
|
|
52
|
+
observer.error(error);
|
|
53
|
+
}
|
|
54
|
+
})();
|
|
55
|
+
|
|
56
|
+
return () => {
|
|
57
|
+
abortController.abort();
|
|
58
|
+
};
|
|
59
|
+
}))
|
|
60
|
+
};
|
|
61
|
+
} // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
addSubscriber(subscriber) {
|
|
65
|
+
this.subscribers.push(subscriber);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
exports.ChatAdapterShim = ChatAdapterShim;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.Deferred = void 0;
|
|
7
|
+
|
|
8
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
9
|
+
|
|
10
|
+
class Deferred {
|
|
11
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
12
|
+
constructor() {
|
|
13
|
+
_defineProperty(this, "_promise", void 0);
|
|
14
|
+
|
|
15
|
+
_defineProperty(this, "_resolve", void 0);
|
|
16
|
+
|
|
17
|
+
_defineProperty(this, "_reject", () => {
|
|
18
|
+
return;
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
_defineProperty(this, "resolve", value => {
|
|
22
|
+
this._resolve(value);
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
_defineProperty(this, "reject", value => {
|
|
26
|
+
this._reject(value);
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
this._promise = new Promise((resolve, reject) => {
|
|
30
|
+
this._resolve = resolve;
|
|
31
|
+
this._reject = reject;
|
|
32
|
+
});
|
|
33
|
+
} // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
get promise() {
|
|
37
|
+
return this._promise;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
exports.Deferred = Deferred;
|